package com.webframe.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;


/**
 * 获取spring信息的工具类
 * @author lenovo
 *
 */
public final class ToolSpring implements ApplicationContextAware
{
	private static ApplicationContext applicationContext = null;
	@Override
	public void setApplicationContext(ApplicationContext applicationContext)
				throws BeansException
	{
		if(ToolSpring.applicationContext == null)
		{
			ToolSpring.applicationContext = applicationContext;
		}
	}
	
	public static ApplicationContext getApplicationContext()
	{
		return applicationContext;
	}
	
	public static Object getBean(String name)
	{
		return getApplicationContext().getBean(name);
	}
}
